using System.IO;

namespace DAC.HttpWeb
{
	public class Attachment
	{
		public string FileName
		{
			get;
			set;
		}

		public string MediaType
		{
			get;
			set;
		}

		public byte[] Data
		{
			get;
			set;
		}

		public string Name
		{
			get;
			set;
		}

		public Attachment(string name, string filename, string mediatype, string filePath)
		{
			this.Name = name;
			this.FileName = filename;
			this.MediaType = mediatype;
			this.Data = null;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				if (File.Exists(filePath))
				{
					using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
					{
						byte[] array = new byte[4096];
						int num = 0;
						while ((num = fileStream.Read(array, 0, array.Length)) != 0)
						{
							memoryStream.Write(array, 0, num);
						}
						this.Data = memoryStream.ToArray();
					}
				}
			}
		}
	}
}
